﻿@{
    ViewData["Title"] = "UnitsShow";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div style="padding-lef:50px;padding-top:50px" align="center"> 
    <button class="layui-btn layui-bg-red" onclick="location.href='/Units/UnitsCreate'"><i class="layui-icon layui-icon-addition"></i>企业新增</button>
</div>


<div style="margin:20px 20px">
    <body>

        <table id="ID-table-demo-setRowChecked"></table>
        <div id="pagesbox"></div>

        <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

        <div id="add-main" style="display: none;">
            <script>
                layui.use(['table', 'laypage', 'layer', 'form', 'layer', 'laydate'], function () {
                    var table = layui.table;
                    var laypage = layui.laypage;
                    var obj = {};
                    var form = layui.form;
                    var layer = layui.layer; // 添加layui弹出层模块
                    var laydate = layui.laydate;
                    // 渲染
                    laydate.render({
                        elem: '#sheeAccounts'
                    });

                    var size = 15; // 每页显示条数
                    //获取列表
                    function getListData(page) {
                        $.ajax({
                            url: 'http://10.31.60.18:8000/AuthorizationGetRout/api/DepartmentShow/UnitsShow',
                            type: 'get',
                            dataType: 'json',
                            data: {
                                page: page,
                                size: size,
                            },
                            success: function (res) {
                                table.render({
                                    elem: '#ID-table-demo-setRowChecked',
                                    cols: [[
                                        { type: 'checkbox', width: 60, fixed: 'center', unresize: true, align: 'center' },
                                        { field: 'number', type: 'numbers', title: '序号', width: 60, fixed: 'center', unresize: true, align: 'center', templet: '#zizeng' },
                                        { field: 'unitFull', title: '企业名称', width: 150, align: 'center' },
                                        { field: 'unitAddress', title: '详细地址', width: 150, align: 'center' },
                                        { field: 'unitPhone', title: '手机号', width: 120, align: 'center' },
                                        {

                                            field: 'unitPrinc', title: '负责人', width: 120, align: 'center',
                                            templet: function (data) {
                                                if (data.unitPrinc == 1) return '张三';
                                                if (data.unitPrinc == 2) return '李四';
                                                if (data.unitPrinc == 3) return '王五';
                                            }
                                        },
                                    ]],
                                    toolbar: '#demo-toolbar-setRowChecked',
                                    initSort: { // 设置初始排序
                                        field: 'experience', // 字段名
                                        type: 'asc' // 倒序
                                    },
                                    height: 500,
                                    data: res.data
                                });
                                //分页
                                laypage.render({
                                    //挂载的分页id
                                    elem: 'pagesbox',
                                    count: res.tatalCount,
                                    limit: size,
                                    curr: page,
                                    layout: ['count', 'prev', 'page', 'next', 'skip'],
                                    jump: function (obj, first) {
                                        if (!first) {
                                            getListData(obj.curr);
                                        }
                                    }
                                });
                            }
                        });
                    }
                    $('#searchBtn').on('click', function () {
                        getListData(1);
                    });
                    // 初始化加载数据
                    $(function () {
                        getListData(1);
                    })
                });
            </script>
            <script type="text/html" id="barDemo">
                <div class="layui-btn-container">
                   
                </div>
            </script>

    </body>
</div>
